<?php 
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$days = array( 	"Sat" => "Sa",
				"Sun" => "So",
				"Mon" => "Mo",
				"Tue" => "Di",
				"Wed" => "Mi",
				"Thu" => "Do",
				"Fri" => "Fr" );

//@todo: load by domain -> website
$templatepath = "template/trassenheide/";
//get information from Google API
$city='Trassenheide';
$language='en';
// Google API Aufruf vorbereiten
$city=str_replace(" ","+",$city);
$target_url = 'http://www.google.com/ig/api?weather='.$city.'&hl='.$language;
$weather = $this->xmltoarray->xmlarray( $target_url, 1, '' );
$current_array = $weather['xml_api_reply']['weather']['current_conditions']; 
$weather_array = $weather['xml_api_reply']['weather']['forecast_conditions']; 
?>
<div id="weather" class="color-box">
<div>
<h3>Wettervorhersage Trassenheide</h3>
<div>
<table border="0" cellpadding="0" cellspacing="0" width="170">
	<tr>
		<?php 
		$count = 1;
		foreach( $weather_array as $key => $value ){
			if( $count <= 3 ) {
				$image = str_replace( "/ig/", "", $value['icon']['attr']['data'] );
				?>
				<td class="tdcenter"><img src="<?php echo DEVPATH.$templatepath.$image;?>" /></td>
				<?php
			}
			$count++;
		}
		?>
	</tr>
	<tr>
		<?php 
		$count = 1;
		foreach( $weather_array as $key => $value ){
			if( $count <= 3 ) {
				echo '<td class="tdcenter">'.$days[$value['day_of_week']['attr']['data']] .'</td>';
			}
			$count++;
		}
		?>
	</tr>
	<tr>
		<td colspan="3" class="tdtop"><?php print $this->lang->line( 'actual_weather' ); ?></td>
	</tr>
	<tr>
		<td>Temp: <?php echo $current_array['temp_c']['attr']['data']; ?>&#8451;</td>
		<td></td>
		<td><?php echo str_replace( array( 'at', 'mph' ), array( '', 'km/h' ), $current_array['wind_condition']['attr']['data'] ); ?></td>
	</tr>
	<tr>
		<td colspan="3" class="tdtop" style="text-align: right; font-weight: normal;"><a href="<?php echo site_url( ); ?>/welcome/page/wetter"><?php print $this->lang->line( 'more' ); ?> &gt;</a></td>
	</tr>
</table>
</div></div></div>
